#include "pintaros.h"
#include "config.h"
#include "state.h"

struct state_struct     state_mng[STATE_MAX_STATE];   ///< state_manager
int                     active_state;           ///< current active state

int stateInitialize()
{
  int i;
  for(i=0;i<STATE_MAX_STATE;i++) {
    state_mng[i].current = 0;
    state_mng[i].currentKey = 0;
    state_mng[i].currentRecord = 0;
    state_mng[i].securityState = 0;
  }
  return 0; 
}

int stateChangeState(int newState)
{
  active_state = newState;

  return 0;
}

int stateVerify(uint8_t *PIN)
{

  return 0;
}

int stateSetCurrent(uint16_t newFile)
{
  state_mng[active_state].current = newFile;
  state_mng[active_state].currentRecord = 0;
  state_mng[active_state].securityState = 0;

  return 0;
}

int stateSetCurrentKey(uint16_t newEFKey)
{
  state_mng[active_state].currentKey = newEFKey;

  return 0;
}

uint16_t stateGetCurrent()
{
  return state_mng[active_state].current;
}

uint8_t stateGetCurrentSecurity()
{
  return state_mng[active_state].securityState;
}
